<template>
    <el-button size="small"
               style="margin-top: 10px;margin-bottom: 10px;float: right;margin-left: 10px;" type="plain"
               class="setting">
        <el-badge :value="num" class="item" @dblclick.native="handleImport(2)" @click.native="handleImport(1)">
            <div style="display: flex;flex-direction: column;"><i class="el-icon-setting"></i><span
                    style="margin-top: 3px">新建出库</span></div>
        </el-badge>
        <daiban-list
                v-bind:dialogshow="dialogStoreAdd"
                @dialog_close="dialogStoreAdd = !dialogStoreAdd"
                @clear_num="clear_num()"
        >
        </daiban-list>
    </el-button>
</template>


<script>
  module.exports = {
    methods: {
      handleImport (val) {
        console.log(val)
        if (val === 1) {
          let num = localStorage.getItem('num') ? localStorage.getItem('num') : 0
          num++
          localStorage.setItem('num', num)
          this.num = num
          this.$message({
            type: 'info',
            message: '添加成功'
          })
        } else if (val === 2) {
          this.dialogStoreAdd = true
          console.log(222)
          // 加入代办

        }
      },
      clear_num () {
        this.num = 0
        localStorage.setItem('num', this.num)
        this.$message({
          type: 'info',
          message: '清空成功'
        })
      }
    },
    created () {
      this.num = localStorage.getItem('num')
    },
    props: ['dialogshow'],
    data () {
      return {
        num: 0,
        dialogStoreAdd: false
      }
    },
    components: {
      'daiban-list': 'url:./daiban-list.vue',
    },
  }
</script>
